package com.kfy.builderdemo.Builder;

/**
 * @ProjectName: BuilderDemo
 * @Package: com.kfy.builderdemo.Builder
 * @Author: K.F.Y
 * @Date: 2021/5/8
 */
public class Product {

    private String partA;
    private String partB;
    private String partC;
    private String partD;

    private Product(){

    }

    @Override
    public String toString() {
        return "Product{" +
                "partA='" + partA + '\'' +
                ", partB='" + partB + '\'' +
                ", partC='" + partC + '\'' +
                ", partD='" + partD + '\'' +
                '}';
    }

    public static class Builder {
        //创建产品对象
        protected Product product = new Product();
        public Builder buildPartA(String partA){
            product.partA = partA;
            return this;
        }
        public Builder buildPartB(String partB){
            product.partB = partB;
            return this;
        }
        public Builder buildPartC(String partC){
            product.partC = partC;
            return this;
        }
        public Builder buildPartD(String partD){
            product.partD = partD;
            return this;
        }
        public Product create(){
            return product;
        }

    }

}
